
    
    <?php if($this->cart){?>
    <div class="title"><h3>Chi tiết giỏ hàng</h3></div>
    <form action="<?php echo $this->baseUrl('cart/update')?>" method="post">
    <div class="table">
    <table class="cart">
        <tr height="30px" style="color: #fdc54b; background: #252525;">
            <th width="30px">Xóa</th>
            <th width="30px">STT</th>            
            <th width="220px">Tên sản phẩm</th>
            <th width="90px">Số lượng</th>
            <th width="100px">Đơn giá</th>
            <th width="100px">Thành tiền</th>
        </tr>
        <?php
        $i = 0; $total = 0;
        foreach ($this->cart->item as $item_cart){?>
        <tr class="content">
            <?php $i++; $total += $item_cart['product']->product_price * $item_cart['quantity'];?>
            
            <td style="text-align: center">
                <a class="del" href="<?php echo $this->baseUrl('cart/del/id/') .$item_cart["product"]->product_id?>" title="Xóa">
                    <img width="20px" height="20px" src="<?php echo $this->baseUrl('default/images/remove.ico')?>" alt="xóa"/>
                </a>
            </td>
            <td style="text-align: center"><?php echo $i;?></td>
            <td><?php echo $item_cart['product']->product_name?></td>
            <td class="quantity" style="text-align: center">
                <input name="num<?php echo $i?>" type="text" style="width:70px; text-align: center;" value="<?php echo $item_cart['quantity']?>"/>
            </td>
            <td style="text-align: center"><?php echo format($item_cart["product"]->product_price);?></td>
            <td style="text-align: center"><?php echo format($item_cart["product"]->product_price * $item_cart['quantity']);?>
        </tr>       
        <?php }?>
        <tr>
            <td style="text-align: center" colspan="5" height="30px">Tổng cộng</td>
            <td style="text-align: center"><?php echo format($total);?></td>
        </tr>
    </table>
    
    </div><!-- end .table -->
    
    
    <div class="function">
        <a class="continue" href="<?php echo $this->baseUrl('/');?>" title="Tiếp tục mua hàng">Mua hàng tiếp</a>
        <input type="submit" value="Cập nhật"/>
        <a class="clear" href="<?php echo $this->baseUrl('cart/remove')?>" title="Xóa hết giỏ hàng">Xóa hết giỏ hàng</a>
        <a class="order" href="<?php echo $this->baseUrl('order/index')?>" title="Đặt hàng">Đặt hàng</a>
        
     </div><!-- end .function -->
</form>
    <?php }?>    
    


<?php function format($number){
    return number_format($number, 0, ',', '.');
}?>

<script>
$(document).ready(function(){
	$("#list-cart a.del").click(function(){
		var _this = $(this);
	    var link = $(this).attr("href");	    
	    $.ajax({
		    url: link,		    
		    });
	    //get data of list cart show in review cart
	    var link2 = "<?php echo $this->baseUrl('cart/list')?>";
		$.ajax({
		    url: link2,
		    dataType: "html",
		    success: function(data){
			    $("#list-cart").html(data);
		    }
		});

		//update shopping-cart
		var link3 = "<?php echo $this->baseUrl('cart/index')?>";
		$.ajax({
		    url: link3,
		    dataType: "html",
		    success: function(rdata){
		        $("#shopping-cart").html(rdata);
			    },
			});
	    return false;
		});
});
</script>

<script>
// $(document).ready(function(){
// 	$("#list-cart form").submit(function(){
// 		var link = $(this).attr("action");
// 		$.ajax({
//             type: "post",
//             url: link,
//             data: $(this).serialize(),
//             dataType: "html",
//             success: function(data){
//             	$("#list-cart .table").empty();
//                 $("#list-cart .table").html(data);
//                 },
//             });
//         return false;
// 		});
// });
</script>